package elementalgit;

import javax.swing.*;
import elementalgit.Wrongframe;
import elementalgit.GameGUI2;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class QuizLogic {

    public static int right = 0;
    public static int wrong = 0;
    public static Boolean a1c;
    public static Boolean a2c;
    public static Boolean a3c;
    int i;
    static String q1 = "If the atomic number of Titanium is 22, how many protons does it have?";
    static String a11 = "11";
    static String a12 = "44";
    static String a13 = "22";
    static String q2 = "How many protons and neutrons does Argon-40 have? (Hint: The"
            + " atomic number of Argon is 18)";
    static String a21 = "40 protons and 40 neutrons";
    static String a22 = "18 protons and 22 neutrons";
    static String a23 = "20 protons and 20 neutrons";
    static String q3 = "What is the isotope notation for Neon 22? (Hint: The atomic "
            + "number of Neon is 10)";
    static String a31 = "22-10-N";
    static String a32 = "10-22-N";
    static String a33 = "11-11-N";
    static String q4 = "How many valence electrons does an ordinary atom of Aluminium "
            + "have? (Hint: The atomic number of Aluminium is 13)";
    static String a41 = "5";
    static String a42 = "1";
    static String a43 = "13";

    public void correct1(String question, String answer1, String answer2,
            String answer3) {
        GameGUI2.jTextField2.setText(question);
        GameGUI2.jTextField1.setText(answer1);
        GameGUI2.jTextField3.setText(answer2);
        GameGUI2.jTextField4.setText(answer3);
    }

    public void correct2(String question, String answer1, String answer2,
            String answer3) {
        Question2.jTextField2.setText(question);
        Question2.jTextField1.setText(answer1);
        Question2.jTextField3.setText(answer2);
        Question2.jTextField4.setText(answer3);
    }

    public void correct3(String question, String answer1, String answer2,
            String answer3) {
        Question3.jTextField2.setText(question);
        Question3.jTextField1.setText(answer1);
        Question3.jTextField3.setText(answer2);
        Question3.jTextField4.setText(answer3);
    }

    public void correct4(String question, String answer1, String answer2,
            String answer3) {
        Question4.jTextField2.setText(question);
        Question4.jTextField1.setText(answer1);
        Question4.jTextField3.setText(answer2);
        Question4.jTextField4.setText(answer3);
    }

    public void first() {
        correct1(q1, a11, a12, a13);
        a1c = false;
        a2c = false;
        a3c = true;
        i = 1;
    }

    public void second() {
        correct2(q2, a21, a22, a23);
        a1c = false;
        a2c = true;
        a3c = false;
        i = 2;
    }

    public void third() {
        correct3(q3, a31, a32, a33);
        a1c = true;
        a2c = false;
        a3c = false;
        i = 3;
    }

    public void fourth() {
        correct4(q4, a41, a42, a43);
        a1c = true;
        a2c = false;
        a3c = false;
        i = 4;
    }

    public void wrong() {
        final Wrongframe wrong = new Wrongframe();
        wrong.setVisible(true);
        int delay = 1000;
        ActionListener taskPerformer = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                wrong.setVisible(false);
            }
        };
        Timer timer = new Timer(delay, taskPerformer);
        timer.setRepeats(false);
        timer.start();
    }

    public void right() {
        final Rightframe right = new Rightframe();
        right.setVisible(true);
        int delay = 1000;
        ActionListener taskPerformer = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                right.setVisible(false);
            }
        };
        Timer timer = new Timer(delay, taskPerformer);
        timer.setRepeats(false);
        timer.start();
    }

    public void nextQ() {
        switch (i) {
            case 1:
                GameGUI2.i = 2;
                break;
            case 2:
                GameGUI2.i = 3;
                break;
            case 3:
                GameGUI2.i = 4;
                break;
            default:
                int a = 0;
        }
    }
}
